﻿<UserControl x:Class="LeoK.DCI.Views.DCIChart"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:converter2="clr-namespace:LeoK.DCI.Converter"
             mc:Ignorable="d" 
             FontSize="12" FontFamily="SimSun"
             d:DesignHeight="1300" d:DesignWidth="1300">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="0.4*" />
        </Grid.RowDefinitions>

        <Grid.Resources>
            <converter2:DCIDiffConverter x:Key="DCIDiffConverter" />
            <converter2:DCIDiffPrecentConverter x:Key="DCIDiffPrecentConverter" />
        </Grid.Resources>

        <StackPanel Orientation="Horizontal" Margin="30,10,0,5">
            <Button Content="编辑" Margin="0, 0, 20, 0" Click="btnEdit_Click" Width="60" Height="23"/>
            <TextBlock x:Name="tbMA7" Foreground="DeepPink" Text="MA5:120.5" />
            <TextBlock x:Name="tbMA30" Foreground="DarkOrange" Text="MA5:120.5" Margin="20,0,0,0" />
            <TextBlock x:Name="tbMA120" Foreground="CadetBlue" Text="MA5:120.5" Margin="20,0,0,0"/>
            <TextBlock x:Name="tbMA360" Foreground="BlueViolet" Text="MA5:120.5" Margin="20,0,0,0"/>
        </StackPanel>

        <StackPanel Orientation="Horizontal" Margin="30,5,0,10" Grid.Row="1">
            <TextBlock x:Name="tbOpen" Foreground="Red" Text="5" />
            <TextBlock x:Name="tbClose" Foreground="Red" Text="5" Margin="20,0,0,0" />
            <TextBlock x:Name="tbHigh" Foreground="Red" Text="5" Margin="20,0,0,0"/>
            <TextBlock x:Name="tbLow" Foreground="Red" Text="5" Margin="20,0,0,0"/>
            <TextBlock x:Name="tbDiff" Foreground="Red" Text="5" Margin="20,0,0,0"/>
        </StackPanel>

        <telerik:RadCartesianChart x:Name="chart" Grid.Row="2" 
                                   MouseMove="RadCartesianChart_OnMouseMove"
                                   PanOffsetChanged="Chart_OnPanOffsetChanged">
            <telerik:RadCartesianChart.Behaviors>
                <telerik:ChartTooltipBehavior Placement="Relative" />
                <telerik:ChartPanAndZoomBehavior x:Name="ZoomBehavior" ZoomMode="Horizontal"  DragMode="Zoom"/>
            </telerik:RadCartesianChart.Behaviors>

            <telerik:RadCartesianChart.Annotations>
                <telerik:CartesianGridLineAnnotation x:Name="VAGridLineAnnotation" Stroke="Goldenrod" StrokeThickness="1" Axis="{Binding ElementName=VAxis}" />
                <telerik:CartesianGridLineAnnotation x:Name="HAGridLineAnnotation" Stroke="Goldenrod" StrokeThickness="1" Axis="{Binding ElementName=HAxis}" />
            </telerik:RadCartesianChart.Annotations>

            <telerik:RadCartesianChart.TooltipTemplate>
                <DataTemplate>
                    <Border Width="150" Height="180" Background="PowderBlue" >
                        <StackPanel Margin="5">
                            <StackPanel Orientation="Horizontal" Margin="5">
                                <TextBlock Text="{Binding Path=DataItem.Date, StringFormat='yyyy/MM/dd dddd', ConverterCulture=zh-CN}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="开盘：" />
                                <TextBlock Text="{Binding Path=Open, StringFormat='0.00'}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="收盘：" />
                                <TextBlock Text="{Binding Path=Close, StringFormat='0.00'}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="最高：" />
                                <TextBlock Text="{Binding Path=High, StringFormat='0.00'}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="最低：" />
                                <TextBlock Text="{Binding Path=Low, StringFormat='0.00'}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="差额：" />
                                <TextBlock Text="{Binding Path=DataItem, Converter={StaticResource DCIDiffConverter}, StringFormat='0.00'}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="幅度：" />
                                <TextBlock Text="{Binding Path=DataItem, Converter={StaticResource DCIDiffPrecentConverter}, StringFormat='0.00%'}" />
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </telerik:RadCartesianChart.TooltipTemplate>

            <telerik:RadCartesianChart.Series>
                <telerik:CandlestickSeries ItemsSource="{Binding Path=DayLines}"
                                           OpenBinding="Open"
                                           HighBinding="High"
                                           LowBinding="Low"
                                           CloseBinding="Close"
                                           CategoryBinding="Date"  >
                    <telerik:CandlestickSeries.DefaultVisualStyle>
                        <Style TargetType="telerik:Candlestick">
                            <Setter Property="MinHeight" Value="1"/>
                            <Setter Property="StrokeThickness" Value="1"/>
                            <Setter Property="UpStroke" Value="Red"/>
                            <Setter Property="DownStroke" Value="ForestGreen"/>
                            <Setter Property="UpFill" Value="Red" />
                            <Setter Property="DownFill" Value="ForestGreen" />
                        </Style>
                    </telerik:CandlestickSeries.DefaultVisualStyle>
                    <telerik:CandlestickSeries.VerticalAxis>
                        <telerik:LinearAxis x:Name="VAxis" LabelFormat="0"/>
                    </telerik:CandlestickSeries.VerticalAxis>
                </telerik:CandlestickSeries>

                <telerik:SplineSeries x:Name="slineMA7"
                                      CategoryBinding="Date"
                                      ValueBinding="Value" VerticalAxis="{Binding ElementName=VAxis}">
                    <telerik:SplineSeries.StrokeShapeStyle>
                        <Style TargetType="Path">
                            <Setter Property="Stroke" Value="DeepPink"/>
                        </Style>
                    </telerik:SplineSeries.StrokeShapeStyle>
                </telerik:SplineSeries>
                <telerik:SplineSeries x:Name="slineMA30"
                                      CategoryBinding="Date"
                                      ValueBinding="Value" VerticalAxis="{Binding ElementName=VAxis}">
                    <telerik:SplineSeries.StrokeShapeStyle>
                        <Style TargetType="Path">
                            <Setter Property="Stroke" Value="DarkOrange"/>
                        </Style>
                    </telerik:SplineSeries.StrokeShapeStyle>
                </telerik:SplineSeries>
                <telerik:SplineSeries x:Name="slineMA120"
                                      CategoryBinding="Date"
                                      ValueBinding="Value" VerticalAxis="{Binding ElementName=VAxis}">
                    <telerik:SplineSeries.StrokeShapeStyle>
                        <Style TargetType="Path">
                            <Setter Property="Stroke" Value="CadetBlue"/>
                        </Style>
                    </telerik:SplineSeries.StrokeShapeStyle>
                </telerik:SplineSeries>
                <telerik:SplineSeries x:Name="slineMA360"
                                      CategoryBinding="Date"
                                      ValueBinding="Value" VerticalAxis="{Binding ElementName=VAxis}">
                    <telerik:SplineSeries.StrokeShapeStyle>
                        <Style TargetType="Path">
                            <Setter Property="Stroke" Value="BlueViolet"/>
                        </Style>
                    </telerik:SplineSeries.StrokeShapeStyle>
                </telerik:SplineSeries>
            </telerik:RadCartesianChart.Series>

            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:DateTimeContinuousAxis  
                    MajorStep="1"
                    MajorStepUnit="Day"
                    MaximumTicks="5"
                    LabelFormat="MM/dd"
                    LabelInterval="7"
                    x:Name="HAxis"
                    PlotMode="BetweenTicks" >
                </telerik:DateTimeContinuousAxis>
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis Width="50" 
                                    x:Name="PrecentVAxis"
                                    MajorStep="0.01"
                                    HorizontalLocation="Right"
                                    LabelFormat="0.00%"
                                    Minimum="-0.1"
                                    Maximum="0.1"/>
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:RadCartesianChart.Grid>
                <telerik:CartesianChartGrid MajorXLinesRenderMode="All"  MajorLinesVisibility="Y"/>
            </telerik:RadCartesianChart.Grid>
        </telerik:RadCartesianChart>

        <Grid Grid.Row="3">
            <telerik:RadCartesianChart Margin="0,0,40,0" x:Name="macdChart"
                                       HorizontalZoomRangeEnd="{Binding ElementName=chart,Path=HorizontalZoomRangeEnd, Mode=TwoWay}"
                                       HorizontalZoomRangeStart="{Binding ElementName=chart,Path=HorizontalZoomRangeStart, Mode=TwoWay}">
                <telerik:RadCartesianChart.Behaviors>
                    <telerik:ChartPanAndZoomBehavior x:Name="MACDZoomBehavior" ZoomMode="Horizontal"  DragMode="Zoom"/>
                </telerik:RadCartesianChart.Behaviors>

                <telerik:RadCartesianChart.Annotations>
                    <telerik:CartesianGridLineAnnotation Value="0" Stroke="CadetBlue"  StrokeThickness="0.5" />
                </telerik:RadCartesianChart.Annotations>
                <telerik:RadCartesianChart.Series>
                    <telerik:SplineSeries x:Name="MacdDIF"
                                          ItemsSource="{Binding Path=MACDDatas}"
                                      CategoryBinding="Date"
                                      ValueBinding="DIFF">
                        <telerik:SplineSeries.StrokeShapeStyle>
                            <Style TargetType="Path">
                                <Setter Property="Stroke" Value="Black"/>
                            </Style>
                        </telerik:SplineSeries.StrokeShapeStyle>
                    </telerik:SplineSeries>
                    <telerik:SplineSeries x:Name="MacdDEA"
                                          ItemsSource="{Binding Path=MACDDatas}"
                                      CategoryBinding="Date"
                                      ValueBinding="DEA">
                        <telerik:SplineSeries.StrokeShapeStyle>
                            <Style TargetType="Path">
                                <Setter Property="Stroke" Value="DarkGoldenrod"/>
                            </Style>
                        </telerik:SplineSeries.StrokeShapeStyle>
                    </telerik:SplineSeries>
                    <telerik:BarSeries x:Name="MacdBAR"
                                          ItemsSource="{Binding Path=MACDDatas}"
                                      CategoryBinding="Date"
                                      ValueBinding="BAR" >
                        <telerik:BarSeries.DefaultVisualStyle>
                            <Style TargetType="Border">
                                <Setter Property="MaxWidth"  Value="2"/>
                                <Setter Property="Background" Value="Red" />
                            </Style>
                        </telerik:BarSeries.DefaultVisualStyle>

                    </telerik:BarSeries>
                </telerik:RadCartesianChart.Series>
                
                
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:DateTimeContinuousAxis  
                    MajorStep="1"
                    MajorStepUnit="Day"
                    MaximumTicks="5"
                    LabelFormat="MM/dd"
                    LabelInterval="7"
                    x:Name="MacdHAxis"
                    PlotMode="BetweenTicks" >
                    </telerik:DateTimeContinuousAxis>
                </telerik:RadCartesianChart.HorizontalAxis>
                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis x:Name="MacdVAxis" LabelFormat="0"/>
                </telerik:RadCartesianChart.VerticalAxis>
            </telerik:RadCartesianChart>
        </Grid>
    </Grid>
</UserControl>
